package com.jbit.service.impl;

import com.jbit.dto.DmItem;
import com.jbit.dto.DmItemType;
import com.jbit.mapper.DmItemMapper;
import com.jbit.mapper.DmItemTypeMapper;
import com.jbit.service.DmItemTypeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DmItemTypeServiceImpl implements DmItemTypeService {
    @Resource
    private DmItemTypeMapper dmItemTypeMapper;
    @Resource
    private DmItemMapper dmItemMapper;

    @Override
    public List<DmItemType> queryItemType(Integer parent) {
        return dmItemTypeMapper.queryItemType(parent);
    }

    @Override
    public List<DmItemType> queryHeaderType() {
        return dmItemTypeMapper.queryHeaderType();
    }

    @Override
    public List<DmItemType> queryAllType() {
        List<DmItemType> typeList = dmItemTypeMapper.queryAllType();
        for (DmItemType dmItemType : typeList) {
            //查询完分类信息后,通过分类信息查询热门项目
            List<DmItem> itemList = dmItemMapper.queryItemByTypeId(dmItemType.getId());
            dmItemType.setHotItems(itemList);
        }
        return typeList;
    }
}
